package testsystem;

//import com.romaremez.testuser.src.questionanswer.Question;

import questionanswer.Question;

import java.io.Serializable;

public class QuestionStep implements Serializable {
    private Question question;
    private String userAnswer;
    private String theme;

    public QuestionStep(Question question) {
        this.question = question;
        this.theme = question.getTheme();
    }

    /**
     * Method displays question with shuffled answers.
     */
    public void printQuestion() {
        System.out.println("Тема: "+question.getTheme());
        question.shuffleAnswers();
        printQuestionAndAnswers();
    }

    @Override
    public boolean equals(Object obj) {
         if (getClass() != obj.getClass()) {
             return false;
         }
         QuestionStep someQuestionStep = (QuestionStep)obj;
        return question.isEqualsQuestions(someQuestionStep.question);
    }

    public void saveAnswer(String userAnswer) {
        this.userAnswer = userAnswer;
    }

    public boolean isCorrect(){
       boolean result=false;
            if (question.isCorrect(userAnswer))
                return result = true;
        return result;
    }

    private void printQuestionAndAnswers() {
        System.out.print(question);
    }

    public String getTheme () {
        return theme;
    }
}
